window.StringUtils = {
	/**
	 * 是否空 1.==undefined 2.=='' 4.==null 5.空数组
	 * 
	 * @param value
	 * @returns {boolean}
	 */
	isBlank : function(str) {
		if (str == undefined || str == "" || str === "" || str == "null"
				|| str === "null" || str == null || str === null
				|| str.length < 1 || str == "undefined") {
			return true;
		} else {
			return false;
		}
	},
	/**
	 * trim所有函数
	 * 
	 * @param valuet
	 * @returns {*|XML|string|void}
	 */
	allTrim : function(str) {
		return str.replace(/\s+/g, "");
	},
	/**
	 * 判断字符长度是否大于l小于m，超过则返回true
	 * 
	 * @param str
	 * @param l
	 * @param m
	 * @returns {Boolean}
	 */
	checkLength : function(str, l, m) {
		var n = 0; // 定义变量n,初始值为0
		for (var i = 0; i < str.length; i++) { // 应用for循环语句,获取表单提交用户名字符串的长度
			var leg = str.charCodeAt(i); // 获取字符的ASCII码值
			if (leg > 255) { // 判断如果长度大于255
				n += 2; // 则表示是汉字为2个字节
			} else {
				n += 1; // 否则表示是英文字符,为1个字节
			}
		}
		if (n > l || n < m) { // 判断用户名的总长度如果超过20个字节,则返回true
			return true;
		} else {
			return false;
		}
	},
	time2day : function(a) {
		var b = new Date(a);
		return {
			year : b.getFullYear(),
			mon : b.getMonth() + 1 < 10 ? '0' + (b.getMonth() + 1) : b
					.getMonth() + 1,
			day : b.getDate() < 10 ? '0' + b.getDate() : b.getDate(),
			hour : b.getHours() < 10 ? '0' + b.getHours() : b.getHours(),
			min : b.getMinutes() < 10 ? '0' + b.getMinutes() : b.getMinutes()
		};
	},
	ChangeDateFormat : function(cellval) {
		try {
			var date = new Date(cellval);
			var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1)
					: date.getMonth() + 1;
			var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date
					.getDate();
			return date.getFullYear() + "-" + month + "-" + currentDate;
		} catch (e) {
			return "";
		}
	},
	getCurrentDayString : function(days) {
		var b = new Date();
		b.setDate(b.getDate() + days);
		return {
			year : b.getFullYear(),
			mon : b.getMonth() + 1 < 10 ? '0' + (b.getMonth() + 1) : b
					.getMonth() + 1,
			day : b.getDate() < 10 ? '0' + b.getDate() : b.getDate(),
			hour : b.getHours() < 10 ? '0' + b.getHours() : b.getHours(),
			min : b.getMinutes() < 10 ? '0' + b.getMinutes() : b.getMinutes(),
			dayString : b.getFullYear()
					+ '-'
					+ (b.getMonth() + 1 < 10 ? '0' + (b.getMonth() + 1) : b
							.getMonth() + 1) + '-'
					+ (b.getDate() < 10 ? '0' + b.getDate() : b.getDate())
		};
	},
	getTimeStamp : function(date) {
		date = date.replace(/-/g, '/');
		var newDate = new Date(date);
		var timestamp = Date.parse(newDate);
		return timestamp / 1000;
	},
	getTheDayOfWeek : function() {
		var date = new Date();
		var strdate = date.getDay();
		switch (strdate) {
		case 0:
			strdate = "星期天";
			break;
		case 1:
			strdate = "星期一";
			break;
		case 2:
			strdate = "星期二";
			break;
		case 3:
			strdate = "星期三";
			break;
		case 4:
			strdate = "星期四";
			break;
		case 5:
			strdate = "星期五";
			break;
		case 6:
			strdate = "星期六";
			break;
		}
		return strdate;
	},
	SetCookie : function(name, value) {
		var Days = 7;
		var exp = new Date();
		exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
		document.cookie = name + "=" + escape(value) + ";expires="
				+ exp.toGMTString();
	},
	SetCookieForDay : function(name, value, Days) {
		var exp = new Date();
		exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
		document.cookie = name + "=" + escape(value) + ";expires="
				+ exp.toGMTString();
	},
	SetCookieForMin : function(name, value, Min) {
		var exp = new Date();
		exp.setTime(exp.getTime() + Min * 60 * 1000);
		document.cookie = name + "=" + escape(value) + ";expires="
				+ exp.toGMTString();
	},
	GetCookie : function(name) {
		var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
		if (arr = document.cookie.match(reg))
			return unescape(arr[2]);
		else
			return null;
	},
	checkPhone : function(phone) {
		var re = /^(0|86|17951)?(13[0-9]|15[012356789]|17[0678]|18[0-9]|14[57])[0-9]{8}$/;
		if (re.test(phone)) {
			return true;
		} else {
			return false;
		}
	},
	checkEmail : function(email) {
		var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/;
		if (reg.test(email)) {
			return true;
		} else {
			return false;
		}
	},
	getScrollTop : function() {
		var scrollTop = document.documentElement.scrollTop
				|| window.pageYOffset || document.body.scrollTop;
		return scrollTop;
	},
	setScrollTop : function(scroll_top) {
		document.documentElement.scrollTop = scroll_top,
				window.pageYOffset = scroll_top,
				document.body.scrollTop = scroll_top;
	},
	SetLocalStorage : function(name, value) {
		window.localStorage.setItem(name, value);
	},
	GetLocalStorage : function(name) {
		return window.localStorage.getItem(name);
	},
	removeLocalStorage : function(name) {
		window.localStorage.removeItem(name);
	},
	showTips : function(tips, height, time) {
		var windowWidth = document.documentElement.clientWidth;
		var tipsDiv = '<div class="tipsClass">' + tips + '</div>';
		$('body').append(tipsDiv);
		$('div.tipsClass').css({
			'bottom' : height + 'px',
			'left' : (windowWidth / 2) - (tips.length * 13 / 2) + 'px',
			'position' : 'absolute',
			'padding' : '10px 10px',
			'background' : '#000',
			'font-size' : 12 + 'px',
			'margin' : '0 auto',
			'text-align' : 'center',
			'width' : 'auto',
			'color' : '#fff',
			'opacity' : '0.7',
			'z-index' : '99999',
			'border-radius' : '5px'
		}).show();
		setTimeout(function() {
			$('div.tipsClass').fadeOut();
			setTimeout(function() {
				$('div.tipsClass').remove();
			}, 500);
		}, (time * 1000));
	},
	showTopTips : function(tips, height, time) {
		var windowWidth = document.documentElement.clientWidth;
		var tipsDiv = '<div class="tipsClass">' + tips + '</div>';
		$('body').append(tipsDiv);
		$('div.tipsClass').css({
			'top' : height + 'px',
			'left' : (windowWidth / 2) - (tips.length * 13 / 2) + 'px',
			'position' : 'absolute',
			'padding' : '10px 10px',
			'background' : '#000',
			'font-size' : 16 + 'px',
			'margin' : '0 auto',
			'text-align' : 'center',
			'width' : 'auto',
			'color' : '#fff',
			'opacity' : '0.7',
			'z-index' : '99999',
			'border-radius' : '5px'
		}).show();
		setTimeout(function() {
			$('div.tipsClass').fadeOut();
			setTimeout(function() {
				$('div.tipsClass').remove();
			}, 500);
		}, (time * 1000));
	},
	getUrlParam : function(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); // 构造一个含有目标参数的正则表达式对象
		var r = window.location.search.substr(1).match(reg); // 匹配目标参数
		if (r != null)
			return decodeURIComponent(r[2]);
		return null; // 返回参数值
	},
	isWeixin : function() {
		var is_weixin = false;
		var ua = navigator.userAgent.toLowerCase();
		if (ua.match(/MicroMessenger/i) == "micromessenger") {
			is_weixin = true;
		}
		return is_weixin;
	},
	isPC : function() {
		if ((navigator.userAgent
				.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
			return false;
		}else{
			return true;
		}
	},
	getMeta : function(name) {
		var meta = document.getElementsByTagName('meta');
		var share_desc = '';
		for (i in meta) {
			if (typeof meta[i].name != "undefined"
					&& meta[i].name.toLowerCase() == name) {
				share_desc = meta[i].content;
			}
		}
		return share_desc;
	}
};
